<template>
	<view class="wap">
		<navbar :parameter='parameter'></navbar>
		<block v-if="videoList.length > 0">
			<navigator class="list-item acea-row" v-for="(item,index) in videoList" :key="index"
				:url="'/pages/user/video/buy_list?id='+item.id+'&noBuy='+1">
				<!-- <navigator class="list-item acea-row" url="/pages/user/video/buy_liss"> -->
				<image :src="imageUrl+item.head_image" class="left" mode="widthFix"></image>
				<view class="cont-box">
					<view class="title"> {{item.title}} </view>
					<view class="cont line1"> {{item.content}} </view>
					<view class="acea-row row-between-wrapper">
						<view class="acea-row row-middle">
							<view class="price"> ¥{{item.sale_price}} </view>
							<view class="yuan-price">¥{{item.market_price}}</view>
						</view>
						<view class="num"> {{item.look}}人学习 </view>
					</view>
				</view>
			</navigator>
		</block>
		<u-empty mode="list" icon="http://cdn.uviewui.com/uview/empty/list.png" text="暂无可学习视频" v-else></u-empty>
		<u-loadmore :status="status" line dashed @loadmore="loadmore" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				parameter: {
					'navbar': '1',
					'return': '1',
					'title': '我的课程列表',
					'color': true,
					'class': 'on'
				},
				imageUrl: this.imageUrl,
				videoList: [],
				status: 'loadmore',
				limit: 10,
				page: 1,
				total_num: '',
			};
		},
		onLoad() {
			this.list(1);
		},
		onShow() {

		},
		onReachBottom() {
			this.loadmore()
		},
		methods: {
			async list(page) {
				const res = await this.$myRequest({
					url: '/api/user/courseLists',
					data: {
						page: page,
						limit: this.limit,
						openid: uni.getStorageSync('openid'),
					}
				})
				this.videoList = [...this.videoList, ...res.data.data];
				this.total_num = res.data.total_num;
			},
			loadmore() {
				console.log(11111)
				if (this.total_num == this.videoList.length) {
					this.status = 'nomore';
				} else {
					this.status = 'loading';
					this.page++;
					this.list(this.page);
				}
				setTimeout(() => {
					if (this.total_num == this.videoList.length) this.status = 'nomore';
					else this.status = 'loading';
				}, 2000)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.wap {
		padding: 30rpx;
		background-color: #fff;
	}

	.list-item {
		padding: 30rpx 0;
		border-bottom: 1px solid #F0F0F0;
	}

	.list-item .left {
		width: 255rpx;
	}

	.list-item .cont-box {
		width: calc(100% - 255rpx);
		padding-left: 30rpx;
	}

	.list-item .cont-box .title {
		font-size: 30rpx;
		color: #000406;
		line-height: 1.8;
	}

	.list-item .cont-box .cont {
		font-size: 26rpx;
		color: #8D8C96;
		margin-bottom: 20rpx;
	}

	.list-item .cont-box .price {
		font-size: 30rpx;
		color: #FF0101;
		margin-right: 10rpx;
	}

	.list-item .cont-box .yuan-price {
		font-size: 28rpx;
		color: #B8B7BD;
		text-decoration: line-through;
	}

	.list-item .cont-box .num {
		font-size: 24rpx;
		color: #8B8994;
	}
</style>
